1. Field of the Invention
This invention relates to a method of reading a two-dimensional code. Also, this invention relates to an apparatus for reading a two-dimensional code. In addition, this invention relates to a recording medium storing a computer program which concerns a two-dimensional code.
2. Description of the Related Art
A two-dimensional code is able to represent a great amount of information in comparison with a typical bar code. On the other hand, reading a two-dimensional code tends to take a longer time than reading a typical bar code.
There is a two-dimensional code composed of cells representing unit pieces of information respectively. Each of the cells is xe2x80x9cwhitexe2x80x9d assigned to a first logic state of a unit information piece, or xe2x80x9cblackxe2x80x9d assigned to a second logic state of the unit information piece. Here, xe2x80x9cwhitexe2x80x9d and xe2x80x9cblackxe2x80x9d correspond to xe2x80x9cbrightxe2x80x9d and xe2x80x9cdarkxe2x80x9d respectively. An apparatus for reading such a two-dimensional code includes a section for determining whether each cell is white or black. For the determining section, it is important to decide the position of the center of each cell.
U.S. Pat. No. 5,408,543 and U.S. Pat. No. 5,410,620 which correspond to Japanese Patent No. 2742555 disclose a system and method for locating and reading digital data in data regions within a data field disposed on a surface of an object to be identified. The system and method in U.S. Pat. No. 5,408,543 and U.S. Pat. No. 5,410,620 include the capability of compensating for optical or physical distortions of the data field as viewed by an optical reader. The data field is defined by X-axis and Y-axis intersecting basic lines disposed at a predetermined angle with respect to each other and a corner mark disposed on the opposite side of the data field from those basic lines. A plurality of position marks for marking predetermined distances between a plurality of imaginary X and Y axis internal lines are also provided. The positions of the imaginary X-axis internal lines within the data field are determinable from their spacings and angles with respect to the Y-axis basic line. The positions of the imaginary Y-axis internal lines are determinable from their spacings and their angles with respect to the X-axis basic line. The locations of the points of intersection of the imaginary X and Y axis internal lines are calculated in order to define data regions within the data field. The system and method compensate for optical and physical distortions of the locations of the X and Y axis basic lines, corner mark and position marks at the time of reading the data in order to accurately locate positions of the data regions within the data field.
It is a first object of this invention to provide an improved method of reading a two-dimensional code.
It is a second object of this invention to provide an improved apparatus for reading a two-dimensional code.
It is a third object of this invention to provide a recording medium storing an improved computer program which concerns a two-dimensional code.
A first aspect of this invention provides a method of reading a two-dimensional code. The method comprises the steps of taking an image of a region including the two-dimensional code; determining a two-dimensional code area in the image, the two-dimensional code area corresponding to the two-dimensional code; setting inspection lines connecting opposite sides in two pairs among four sides indicating boundaries of the two-dimensional code area in cases where the two-dimensional code is of a cell matrix type, and setting inspection lines connecting opposite sides in one pair among four sides indicating boundaries of the two-dimensional code area in cases where the two-dimensional code is of a bar-code stack type; and reading information from the two-dimensional code area on the basis of the inspection lines. The inspection-line setting step comprises setting division points on the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of arrangements of cells in the two-dimensional code in cases where the two-dimensional code is of the cell matrix type, setting division points on the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of stacked bar codes in the two-dimensional code in cases where the two-dimensional code is of the bar-code stack type, and setting the inspection lines which connect corresponding ones of the division points.
A second aspect of this invention provides a method of reading a two-dimensional code of a cell matrix type. The method comprises the steps of taking an image of a region including the two-dimensional code; determining a two-dimensional code area in the image, the two-dimensional code area corresponding to the two-dimensional code; setting inspection lines connecting opposite sides in two pairs among four sides indicating boundaries of the two-dimensional code area; and reading information from the two-dimensional code area on the basis of the inspection lines. The inspection-line setting step comprises detecting a specified pattern in the two-dimensional code area, calculating positions of centers of given cells in the two-dimensional code on the basis of the specified pattern, setting the calculated center positions as division points on first one of the opposite sides, setting division points on second one of the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of arrangements of cells in the two-dimensional code, and setting the inspection lines which connect corresponding ones of the division points.
A third aspect of this invention provides a method of reading a two-dimensional code. The method comprises the steps of taking an image of a region including the two-dimensional code; determining a two-dimensional code area in the image, the two-dimensional code area corresponding to the two-dimensional code; setting inspection lines connecting opposite sides in two pairs among four sides indicating boundaries of the two-dimensional code area in cases where the two-dimensional code is of a cell matrix type, and setting inspection lines connecting opposite sides in one pair among four sides indicating boundaries of the two-dimensional code area in cases where the two-dimensional code is of a bar-code stack type; and reading information from the two-dimensional code area on the basis of the inspection lines. The inspection-line setting step comprises setting division points on the opposite sides in response to a ratio in length between a reference adjacent side connecting first ends of the opposite sides and a line segment parallel with the reference adjacent side and extending from a second end of first one of the opposite sides to second one of the opposite sides, and in response to a number of arrangements of cells in the two-dimensional code in cases where the two-dimensional code is of the cell matrix type, setting division points on the opposite sides in response to a ratio in length between a reference adjacent side connecting first ends of the opposite sides and a line segment parallel with the reference adjacent side and extending from a second end of first one of the opposite sides to second one of the opposite sides, and in response to a number of stacked bar codes in the two-dimensional code in cases where the two-dimensional code is of the bar-code stack type, and setting the inspection lines which connect corresponding ones of the division points.
A fourth aspect of this invention provides a two-dimensional code reading apparatus comprising image taking means for taking an image of a region including a two-dimensional code of a cell matrix type; area determining means for determining a two-dimensional code area in the image taken by the image taking means, the two-dimensional code area corresponding to the two-dimensional code; inspection line setting means for setting inspection lines connecting opposite sides in two pairs among four sides indicating boundaries of the two-dimensional code area determined by the area determining means; and cell reading means for determining intersections of the inspection lines set by the inspection line setting means to be cell positions, and detecting types of cells in the two-dimensional code in response to the determined cell positions. The inspection line setting means comprises means for setting division points on the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of arrangements of cells in the two-dimensional code, and means for setting the inspection lines which connect corresponding ones of the division points.
A fifth aspect of this invention provides a two-dimensional code reading apparatus comprising image taking means for taking an image of a region including a two-dimensional code of a bar-code stack type; area determining means for determining a two-dimensional code area in the image taken by the image taking means, the two-dimensional code area corresponding to the two-dimensional code; inspection line setting means for setting inspection lines connecting opposite sides in one pair among four sides indicating boundaries of the two-dimensional code area determined by the area determining means; and bar-code reading means for scanning the two-dimensional code area along the inspection lines set by the inspection line setting means, and reading bar-code information from the two-dimensional code area. The inspection line setting means comprises means for setting division points on the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of stacked bar codes in the two-dimensional code, and means for setting the inspection lines which connect corresponding ones of the division points.
A sixth aspect of this invention is based on the fourth aspect thereof, and provides a two-dimensional code reading apparatus wherein the inspection line setting means comprises means for detecting a specified pattern in the two-dimensional code area, means for calculating positions of centers of given cells in the two-dimensional code on the basis of the specified pattern, means for setting the calculated center positions as division points on first one of the opposite sides, means for setting division points on second one of the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of arrangements of cells in the two-dimensional code, and means for setting the inspection lines which connect corresponding ones of the division points.
A seventh aspect of this invention is based on the sixth aspect thereof, and provides a two-dimensional code reading apparatus wherein the inspection line setting means comprises means for scanning a group of pixels corresponding to a dark portion in a timing cell array in the two-dimensional code area along a main scanning direction and a sub scanning direction, means for selecting two outermost pixels from the scanned pixel group in the main scanning direction, means for selecting two outermost pixels from the scanned pixel group in the sub scanning direction, means for calculating a position intermediate among the selected outermost pixels in the main scanning direction and the sub scanning direction, and means for using the calculated intermediate position as one of the calculated center positions.
An eighth aspect of this invention is based on the sixth aspect thereof, and provides a two-dimensional code reading apparatus wherein the inspection line setting means comprises means for calculating coordinates of centers of dark portions in a timing cell array in the two-dimensional code area, means for calculating coordinates of centers of bright portions in the timing cell array in the two-dimensional code area from the calculated coordinates of the centers of the dark portions, and means for using the calculated coordinates of the centers of the dark portions and the bright portions as the calculated center positions.
A ninth aspect of this invention provides a two-dimensional code reading apparatus comprising image taking means for taking an image of a region including a two-dimensional code of a cell matrix type; area determining means for determining a two-dimensional code area in the image taken by the image taking means, the two-dimensional code area corresponding to the two-dimensional code; inspection line setting means for setting inspection lines connecting opposite sides in two pairs among four sides indicating boundaries of the two-dimensional code area determined by the area determining means; and cell reading means for determining intersections of the inspection lines set by the inspection line setting means to be cell positions, and detecting types of cells in the two-dimensional code in response to the determined cell positions. The inspection line setting means comprises means for setting division points on the opposite sides in response to a ratio in length between a reference adjacent side connecting first ends of the opposite sides and a line segment parallel with the reference adjacent side and extending from a second end of first one of the opposite sides to second one of the opposite sides, and in response to a number of arrangements of cells in the two-dimensional code, and means for setting the inspection lines which connect corresponding ones of the division points.
A tenth aspect of this invention provides a recording medium storing a computer program for implementing a method of reading a two-dimensional code. The method comprises the steps of taking an image of a region including the two-dimensional code; determining a two-dimensional code area in the image, the two-dimensional code area corresponding to the two-dimensional code; setting inspection lines connecting opposite sides in two pairs among four sides indicating boundaries of the two-dimensional code area in cases where the two-dimensional code is of a cell matrix type, and setting inspection lines connecting opposite sides in one pair among four sides indicating boundaries of the two-dimensional code area in cases where the two-dimensional code is of a bar-code stack type; and reading information from the two-dimensional code area on the basis of the inspection lines. The inspection-line setting step comprises setting division points on the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of arrangements of cells in the two-dimensional code in cases where the two-dimensional code is of the cell matrix type, setting division points on the opposite sides in response to a ratio in length between sides adjacent to the opposite sides and a number of stacked bar codes in-the two-dimensional code in cases where the two-dimensional code is of the bar-code stack type, and setting the inspection lines which connect corresponding ones of the division points.